#!/usr/bin/perl -w

use strict;

my ($album, $artist, $price); 

format =
  Album=@<<<<<<<<<< Artist=@>>>>>>>>>> Price=$@##.##
        $album,        $artist,       $price
.

format STDOUT_TOP = 
  @|||||||||||||||||||||||||||||||||||||| Pg @<
  "CD Collection of YL",                     $%

  Album            Artist=          Price
  --------------   ---------------  ----------
.

$= = 6;
$^L = '-' x 60 . "\n" . 
      "Copyright, 2011, Amazon.com\n" .
      "\n\n";

my @file;
my $counter = 0;

while (<STDIN>) {
   chomp;
   ($album, $artist, $price) = split(/!/);
# map -- not good, use for instead of map for in place processing of a list
#   ($album, $artist, $price) = map 
#        {defined($_) ? $_ : "" } ($album, $artist, $price);

# for -- not as good.  for price we want to define it as 0
#   for my $v ($album, $artist, $price) {
#      $v = "" unless defined $v;
#   }

   $album = "" unless defined($album);
   $artist = "" unless defined($artist);
   $price = 0 unless defined($price);

   $file[$counter++] = "Album = $album, Artist = $artist, Price = $price\n";
   write();
}

#print ("$^L");

print ("\n" x $- . "$^L"); 
